const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const cors = require('cors');
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');

//后台路由文件
const adminLoaddataRouter = require('./routes/admin/loaddata');
const adminLoaddataPostRouter = require('./routes/admin/loaddatabypost');
const adminD_ICPMSRouter = require('./routes/admin/D_ICPMS');
const adminUPbWetherillRouter = require('./routes/admin/UPbWetherill');
const adminUPbTeraWasserburgRouter = require('./routes/admin/UPbTeraWasserburg')
const app = express();
app.use(cors());
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);
//后台路由配置
app.use('/admin/loaddata', adminLoaddataRouter);
app.use('/admin/loaddatabypost', adminLoaddataPostRouter);
app.use('/admin/DICPMS', adminD_ICPMSRouter);
app.use('/admin/UPbWetherill', adminUPbWetherillRouter);
app.use('/admin/UPbTeraWasserburg', adminUPbTeraWasserburgRouter)

module.exports = app;
